<?php
require_once $_site->get_viewpath("boss/common/authcheck");
require_once $_site->get_viewpath("mobile/common/header");

//查询管理员信息
$boss_object=new boss();

$typeAry=array(1=>'挖机装车 ',2=>'挖机计时',3=>'渣车登记');

$page=request('page',false,true,false,1);

$cond['type']=request('type',true,false,false,0);
$cond['did']=request('did',true,false,false,0);
$cond['date']=request('date');

$cols='id,img,type,dno,time,ctime,dname,truck,dust';
$list=$boss_object->record_search($cond,$page,20,$cols);

$device_list=$boss_object->car_active('carno,codeid');

//时间
$datestr=date('Y');

unset($cond['pid']);
$querystr=http_build_query($cond);
?>	
</head>

	<body>
		<div class="headertwo clearfloat" id="header">
			<a href="javascript:history.go(-1)" class="fl box-s"><i class="iconfont icon-arrow-l fl"></i></a>
			<p class="fl"><?php echo $cond['type']?$typeAry[$cond['type']]:'全部记录'; ?></p>
			<a href="/boss/center" class="fr"><i class="iconfont icon-gerenzhongxin fl"></i></a>
		</div>		
		<div class="clearfloat" id="main">
			<div class="menu-list clearfloat am-sharetwo">
				<ul class="yiji" id="oe_menu">
					<li>
						<a href="#" class="inactive">类型<i></i></a>
						<ul style="display: none">						
						    <li><a href="?<?php $pcond=$cond;unset($pcond['type']);$pquerystr=http_build_query($pcond);echo $pquerystr;?>">全部类型</a></li>
						    <?php 
						       if($typeAry){
                                 foreach($typeAry as $key=>$val){
						    ?>
							<li><a href="?<?php echo $pquerystr;?>&type=<?php echo $key;?>"><?php echo $val;?></a></li> 
							<?php 
							   }}
							?> 						
						</ul>
					</li>
					<li>
						<a href="#" class="inactive">车牌<i></i></a>
						<ul style="display: none">
						<div class="menu_option">
						    <li><a href="?<?php $dcond=$cond;unset($dcond['did']);$pquerystr=http_build_query($dcond);echo $pquerystr;?>">全部车牌</a></li>
						    <?php 
						       if($device_list){
                                 foreach($device_list as $val){
						    ?> 
							<li><a href="?<?php echo $pquerystr;?>&did=<?php echo $val['codeid'];?>"><?php echo $val['carno']; ?></a></li> 
							<?php }}?> 
						</div>	
						</ul>
					</li>
					<li>
						<a href="#" class="inactive">时间<i></i></a>
						<ul style="display: none">
						    <li><a id="datebtn" href="?<?php $tcond=$cond;$tcond['date']=1;$pquerystr=http_build_query($tcond);echo $pquerystr;?>">不限时间</a></li>
						   <li><a href="javascript:;" id="timebtn" data-options='{"type":"date","beginYear":2016,"endYear":<?php echo $datestr;?>}' class="btn">选择时间</a></li>
						</ul>
					</li>
				</ul>
			</div>
									
			<div class="<?php echo $list['rows']?'recom ':'';?>clearfloat recomtwo">
		    	<div class="content clearfloat box-s">
		    	
			 	    <?php 		
			 	       $_header = 0;
			 	       if($list['rows']){
                          foreach ($list['rows'] as $vo){	
							if($_header){
								$length=$_header-$vo['ctime'];
							}
							$_header=$vo['ctime'];
							$_class=($length>900||$length<90)?'recom-bottom-warn':'recom-bottom';						
			 	    ?>		    	
		    		<div class="list clearfloat fl box-s">
		    			    <a href="/boss/recordinfoall?id=<?php echo $vo['id']?>">
			    			<div class="tu clearfloat">
			    				<span></span>
			    				<img src="<?php echo $vo['img'];?>"/>
			    			</div>
			    		    </a>
			    			<div class="right clearfloat">
			    				<div class="tit clearfloat">
			    					<p class="fl" style="width: 50%;"><?php echo $vo['dno'] ;?></p>
			    					<span class="fr"><samp><?php echo date('Y-m-d H:i:s',$vo['ctime']);?></samp></span>
			    				</div>
			    				<p class="recom-jianjie"><?php echo '车牌：'.$vo['dname'];?></p>
			    				<p class="recom-jianjie"><?php echo "类型：".$typeAry[$vo['type']];?></p>		
			    				<?php 
			    				  if($cond['did']){ 
			    				?>
			    				<div class="<?php echo $_class;?> clearfloat">
			    					<span><i class="warn iconfont icon-time"></i> <?php echo timeparsesecond($length);?></span>			    					
			    				</div>			   
			    				<?php 
			    				  }
			    				?> 					    				
			    			</div>
		    		</div>
		    		<?php
                       }}else{
		    		?>
		    		
						<div class="empty-list clearfloat" id="main">
							<i class="iconfont icon-meineirong"></i>
							<p><?php echo $cond['date']?'[ '.$cond['date'].' ]':'';?>没有找到相应记录！</p>
						</div>		    		
 
                     <?php } ?>
                      
		    	</div>
		    </div>
		    
			<?php 
			   if($list['page_count']>1){
			?>	
			<br/>
			<div class="mui-content-padded">
				<ul class="mui-pager">
					<li class="mui-previous">	
					    <?php 
					       if($page<=1){
					    ?>				
						<a href="javascript:;">上一页</a>
						<?php
                           }else{
						?>
						<a href="?<?php echo $querystr;?>&page=<?php echo $page-1;?>">上一页</a>
						<?php } ?>
					</li>
					<li class="mui-disabled">
						<span> <?php echo $page.' / '.$list['page_count'].'  ('.$list['row_count'].')'; ?> </span>
					</li>					
					<li class="mui-next">
					    <?php 
					       if($page>=$list['page_count']){
					    ?>				
						<a href="javascript:;">下一页</a>
						<?php
                           }else{
						?>
						<a href="?<?php echo $querystr;?>&page=<?php echo $page+1;?>">下一页</a>
						<?php } ?>
					</li>
				</ul>
			</div>	
			<?php } ?>		    
		    
	    </div>
	</body>	
	<script type="text/javascript" src="/static/mobile/js/psong.js" ></script>	
	<script type="text/javascript" src="/static/mobile/js/menu.js" ></script>	
	<link href="/static/mobile/css/mui.picker.min.css" rel="stylesheet" />
	<script src="/static/mobile/js/mui.picker.min.js"></script>            
	<script>
		mui.init();
		(function($) {			
		    var result = $('#datebtn')[0];
			var btn=$("#timebtn")[0];
				btn.addEventListener('tap', function() {
					var optionsJson = this.getAttribute('data-options') || '{}';
					var options = JSON.parse(optionsJson);
					var id = this.getAttribute('id');
					var picker = new $.DtPicker(options);
					menuinit();
					picker.show(function(rs) {
						picker.dispose();						
						location.href=result.href+'&date='+rs.text;					
					});
				}, false);
			
		})(mui);
	</script>	
</html>